package org.smr.ministore.micro.client;

import org.blade.utils.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smr.ministore.entities.GoodsSpecificationItem;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Map;

import feign.hystrix.FallbackFactory;


@Component
public class HystrixGoodsSpecificationItemClientFactory implements FallbackFactory<FeignGoodsSpecificationItemMicroServiceClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(HystrixGoodsSpecificationItemClientFactory.class);

    @Override
    public FeignGoodsSpecificationItemMicroServiceClient create(Throwable cause) {
        HystrixGoodsSpecificationItemClientFactory.LOGGER.info("fallback; reason was: {}", cause.getMessage());

        return new FeignGoodsSpecificationItemMicroServiceClient() {

            @Override
            public int batchSave(List<GoodsSpecificationItem> entities) {
                return -1;
            }

            @Override
            public int batchModify(List<GoodsSpecificationItem> entities) {
                return -1;
            }

            @Override
            public int save(GoodsSpecificationItem entity) {
                return -1;
            }

            @Override
            public int updateById(GoodsSpecificationItem id) {
                return -1;
            }

            @Override
            public GoodsSpecificationItem queryById(Long id) {
                GoodsSpecificationItem goodsSpecificationItem = new GoodsSpecificationItem();
                goodsSpecificationItem.setId(-1L);
                return goodsSpecificationItem;
            }

            @Override
            public int deleteById(Long id) {
                return -1;
            }

            @Override
            public Pager<GoodsSpecificationItem> paginate(GoodsSpecificationItem entity, Long pageSize, Long pageNum) {
                Pager<GoodsSpecificationItem> pager = new Pager<GoodsSpecificationItem>();
                pager.setTotalCount(-1L);
                return pager;
            }

            @Override
            public int deleteByIdLogical(Long id) {
                return -1;
            }

        };//Return end
    }
}